/*
 * @Description: 
 * @Version: 2.0
 * @Autor: ftt
 * @Date: 2022-06-10 14:29:26
 * @LastEditors: TT
 * @LastEditTime: 2022-06-24 18:05:19
 */

import 'dart:math';
import '../config/config_index.dart';
import '../pages/login_module/routers/login_page_id.dart';
import 'common_sp_util.dart';

class UtilsTool {
  /// 判断用户是否登录
  static userislogin() {
    bool islogin = true;
    String? token = CommonSpUtil.getUserToken();
    if (token == null || token == "") {
      islogin = false;
    }
    return islogin;
  }

  /// 配置入口
  static configrootpageid() {
    String rootroute = PageIdConfig.index;
    int intal = CommonSpUtil.getfirstinstal();
    if (intal == 0 && !userislogin()) {
      rootroute = LoginPageId.login;
    } else if (!userislogin()) {
      rootroute = LoginPageId.login;
    }
    return rootroute;
  }
}

/// 生成随机数
int configRandom(int num) {
  var rng = Random();
  return rng.nextInt(num);
}

// 获取配置语言
List<String> configlaunch() {
  List<String> list = ["zh", 'CN'];
  String launch = CommonSpUtil.getLaunchType();
  List<String> lochlist = launch.split('_');
  if (lochlist.length == 2) {
    list = lochlist;
  }
  return list;
}
